#include "Plane.h"
#include <cmath>
#include <stdlib.h>
#include <stdio.h>

void Plane::add(float d, Vector3<float> n){
    distance = d;
    normal = n;
    material = new Material();
}


Vector3<float> Plane::getNormal(Vector3<float> surfacePoint){
    return normal;
}

float Plane::intersect(Ray& r){
    float vd, vo, t=0;

    vd = normal * r.direction;

    if(vd < 0){
      vo = -(normal * r.origin + distance);
      if(vo < 0)  {
            t = vo/vd;
      }
    }

    return t;


}






